package com.xxl.job.admin.utils;

import com.sq.universe.base.entity.BusinessException;
import com.sq.universe.base.utils.AuthUtils;
import com.sq.universe.system.entity.UserEntity;
import com.xxl.job.admin.core.model.XxlJobUser;
import com.xxl.job.admin.core.util.I18nUtil;
import com.xxl.job.admin.dao.XxlJobUserDao;
import com.xxl.job.core.biz.model.ReturnT;

import static com.xxl.job.admin.XxlJobAdminApplication.springbootContext;

public class XxljobUserUtils {
    public static   XxlJobUserDao xxlJobUserDao  = (XxlJobUserDao)springbootContext.getBean("xxlJobUserDao");
    public static XxlJobUser getXxlJobUser(){
        UserEntity userEntity = AuthUtils.getCurrentUser();
        if(userEntity == null || userEntity.getUserId() == null){
            throw new BusinessException("401","用户信息获取失败");
        }
        XxlJobUser xxlJobUser = xxlJobUserDao.loadByUserName(userEntity.getUserLoginName());
        return xxlJobUser;
    }
}
